package o;

import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.extractor.ts.TsPayloadReader.a;

public final class agi implements agc {
    private long ʻ;
    private int ʼ;
    private int ʽ;
    private String ˊ;
    private long ˊॱ;
    private final anc ˋ;
    private aef ˎ;
    private final String ˏ;
    private final aed ॱ;
    private int ॱˊ;
    private boolean ॱॱ;
    private boolean ᐝ;

    public agi() {
        this(null);
    }

    public agi(String str) {
        this.ʽ = 0;
        this.ˋ = new anc(4);
        this.ˋ.ˏ[0] = (byte) -1;
        this.ॱ = new aed();
        this.ˏ = str;
    }

    public void ˏ() {
        this.ʽ = 0;
        this.ʼ = 0;
        this.ॱॱ = false;
    }

    public void ˏ(ady o_ady, a aVar) {
        aVar.ˊ();
        this.ˊ = aVar.ˎ();
        this.ˎ = o_ady.ˊ(aVar.ˏ(), 1);
    }

    public void ˋ(long j, int i) {
        this.ˊॱ = j;
    }

    public void ˊ(anc o_anc) {
        while (o_anc.ˊ() > 0) {
            switch (this.ʽ) {
                case 0:
                    ॱ(o_anc);
                    break;
                case 1:
                    ˋ(o_anc);
                    break;
                case 2:
                    ˎ(o_anc);
                    break;
                default:
                    throw new IllegalStateException();
            }
        }
    }

    public void ˋ() {
    }

    private void ॱ(anc o_anc) {
        byte[] bArr = o_anc.ˏ;
        int ˋ = o_anc.ˋ();
        int ॱ = o_anc.ॱ();
        int i = ˋ;
        while (i < ॱ) {
            boolean z = (bArr[i] & 255) == 255;
            if (this.ॱॱ && (bArr[i] & 224) == 224) {
                int i2 = 1;
            } else {
                boolean z2 = false;
            }
            this.ॱॱ = z;
            if (i2 != 0) {
                o_anc.ˋ(i + 1);
                this.ॱॱ = false;
                this.ˋ.ˏ[1] = bArr[i];
                this.ʼ = 2;
                this.ʽ = 1;
                return;
            }
            i++;
        }
        o_anc.ˋ(ॱ);
    }

    private void ˋ(anc o_anc) {
        int min = Math.min(o_anc.ˊ(), 4 - this.ʼ);
        o_anc.ˎ(this.ˋ.ˏ, this.ʼ, min);
        this.ʼ = min + this.ʼ;
        if (this.ʼ >= 4) {
            this.ˋ.ˋ(0);
            if (aed.ˋ(this.ˋ.ॱᐝ(), this.ॱ)) {
                this.ॱˊ = this.ॱ.ॱ;
                if (!this.ᐝ) {
                    this.ʻ = (1000000 * ((long) this.ॱ.ᐝ)) / ((long) this.ॱ.ˊ);
                    this.ˎ.ˎ(Format.ˎ(this.ˊ, this.ॱ.ˏ, null, -1, 4096, this.ॱ.ˋ, this.ॱ.ˊ, null, null, 0, this.ˏ));
                    this.ᐝ = true;
                }
                this.ˋ.ˋ(0);
                this.ˎ.ˎ(this.ˋ, 4);
                this.ʽ = 2;
                return;
            }
            this.ʼ = 0;
            this.ʽ = 1;
        }
    }

    private void ˎ(anc o_anc) {
        int min = Math.min(o_anc.ˊ(), this.ॱˊ - this.ʼ);
        this.ˎ.ˎ(o_anc, min);
        this.ʼ = min + this.ʼ;
        if (this.ʼ >= this.ॱˊ) {
            this.ˎ.ˋ(this.ˊॱ, 1, this.ॱˊ, 0, null);
            this.ˊॱ += this.ʻ;
            this.ʼ = 0;
            this.ʽ = 0;
        }
    }
}
